package cn.rongdao.jrkabao.base;

import android.text.TextUtils;

import com.bumptech.glide.Glide;
import com.bumptech.glide.util.Util;
import com.mifengkong.frtools.http.request.event.CompulsoryDownLineEvent;
import com.mifengkong.greendao.bean.FundAndActivityCenterUrlBean;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import cn.rongdao.jrkabao.dao.FundAndActivityCenterUrlDao;
import cn.rongdao.jrkabao.ui.webview.WebViewActivity;

/**
 *
 */

public abstract class BaseAutoFinishActivity extends BaseActivity {


    @Override
    protected void initView() {
    }

    @Override
    protected boolean useEventBus() {
        return true;
    }

    public void onDestroy() {
        super.onDestroy();
        if (Util.isOnMainThread() && !isFinishing()) {
            Glide.with(this).pauseRequests();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN) //在ui线程执行
    public void compulsoryDownLineMessage(CompulsoryDownLineEvent compulsoryDownLineEvent) {
        finish();
    }

    protected void startHelpCenter() {
        String helpCenterUrl = null;
        FundAndActivityCenterUrlBean bean = FundAndActivityCenterUrlDao.getInstance().queryObject();
        if (bean != null)
            helpCenterUrl = bean.getHelpcenter_url();
        if (!TextUtils.isEmpty(helpCenterUrl)) {
            WebViewActivity.start(this, helpCenterUrl);
        }
    }
}